import axios from 'axios';
import {
    Message
} from 'element-ui';
const request = axios.create({
    baseURL: 'https://mallapi.duyiedu.com/'
})
request.interceptors.response.use((resp) => {
    // 请求完成
    console.log(resp);
    if (resp.data.status === 'fail') {
        Message.error(resp.data.msg)
        if (resp.data.data) {
            return Promise.resolve(resp.data.data);
        }
    } else if (resp.data.status === 'success') {
        Message({
            type: "success",
            message: resp.data.msg
        })
        if (resp.data.data) {
            return Promise.resolve(resp.data.data);
        }
    } else {
        return resp;
    }

}, (err) => {
    console.log(err);
})

export default request;